package internact;

import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("all")

/**
 * 会员类
 */
public class Member {
    private String username;
    private String password;
    private String name;
    private String phone;
    private double fee;
    private boolean online;
    private List<String> logoutRecords;

    public Member(String username, String password, String name, String phone, double fee) {
        this.username = username;
        this.password = password;
        this.name = name;
        this.phone = phone;
        this.fee = fee;
        this.online = false;
        this.logoutRecords = new ArrayList<>();
    }

    public boolean login(String password) {
        if (this.password.equals(password)) {
            online = true;
            return true;
        } else {
            return false;
        }
    }

    public boolean logout() {
        if (online) {
            online = false;
            logoutRecords.add("注销时间：" + System.currentTimeMillis());
            return true;
        } else {
            return false;
        }
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public double getFee() {
        return fee;
    }

    public void setFee(double fee) {
        this.fee = fee;
    }

    public boolean isOnline() {
        return online;
    }

    public List<String> getLogoutRecords() {
        return logoutRecords;
    }

    @Override
    public String toString() {
        return "用户名：" + username + "\n" +
                "姓名：" + name + "\n" +
                "电话：" + phone + "\n" +
                "会费：" + fee + "\n" +
                "在线状态：" + (online ? "在线" : "离线");
    }
}

